﻿Public Class databindingpage
    Inherits System.Web.UI.Page

    Protected paysValeur = "Aucune valeur sélectionnée"
    Protected paysCle = "Aucune cle sélectionnée"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If ddlPays.Items.Count = 0 Then

            Dim hState As New Hashtable

            hState.Add("FR", "France")
            hState.Add("BE", "Belgique")
            hState.Add("CA", "Canada")
            hState.Add("CH", "Suisse")

            For Each dictEntPays As DictionaryEntry In hState

                Dim itemPays As New ListItem
                itemPays.Value = dictEntPays.Key
                itemPays.Text = dictEntPays.Value
                ddlPays.Items.Add(itemPays)

            Next

        End If

        Me.DataBind()

    End Sub

    Protected Sub dataBindSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlPays.SelectedIndexChanged

        paysValeur = ddlPays.SelectedItem.Text
        paysCle = ddlPays.SelectedItem.Value

        Me.DataBind()

    End Sub

End Class